
complications1 = c(
  rep(1,3),
  rep(2,5),
  rep(3,6),
  rep(4,7),
  rep(5,18)
)
complications2 = c(
  rep(1,5),
  rep(2,3),
  rep(3,4),
  rep(4,3),
  rep(5,25)
)
group = c(rep(1,length(complications1)),rep(2,length(complications2)))
group_labels = c('观察组','对照组')

complications_labels = c('Frey综合征','暂时性面瘫','涎瘘','耳垂区麻木','无并发症')

complications = c(complications1,complications2)

library(expss)
library(haven)
library(dplyr)

df = data.frame(
  group=factor(group,labels = group_labels),
  complications=factor(complications,labels=complications_labels)
)

df = apply_labels(df,group='分组',complications='并发症')
write_sav(df,'ch6_exe1.sav')